﻿using System;

namespace CnSharp.IO
{
    public class ZipClient
    {
        // Events
        public event EventHandler AfterUnzipCompleted;

        public event EventHandler AfterZipFolderCompleted;

        // Methods
        public void Unzip(string zipFile, string targetFolder)
        {
            ZipUtil.Unzip(zipFile, targetFolder);
        }

        public void UnzipAsync(string zipFile, string targetFolder)
        {
            Unzip(zipFile, targetFolder);
            if (AfterUnzipCompleted != null)
            {
                AfterUnzipCompleted(this, EventArgs.Empty);
            }
        }

        public void ZipFolder(string sourceDir, string zipFile)
        {
            ZipUtil.ZipFolder(sourceDir, zipFile);
        }

        public void ZipFolderAsync(string sourceDir, string zipFile)
        {
            ZipFolder(sourceDir, zipFile);
            if (AfterZipFolderCompleted != null)
            {
                AfterZipFolderCompleted(this, EventArgs.Empty);
            }
        }
    }
}